//-----------------------------------------------------------------------
// <copyright file="RoleAssignmentCollection.cs" company="Alan Rodrigues">
//     Copyright (c) Alan Rodrigues. All rights reserved.
// </copyright>
// <developed>Alan Rodrigues (operninha@gmail.com)</developed>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using Microsoft.Interop.Security.AzRoles;

namespace Authorization
{
    /// <summary>
    ///  <see cref="RoleAssignment"/> collection
    /// </summary>
    public class RoleAssignmentCollection : System.Collections.ObjectModel.Collection<RoleAssignment> 
    {
        /// <summary>
        /// default constructor
        /// </summary>
        public RoleAssignmentCollection()
        {                        
        }

        public RoleAssignmentCollection(IList<RoleAssignment> list)
            : base(list)
        { 
        }

        ///// <summary>
        /////  Initializes a instance of the RoleCollection class that is empty and has the specified initial capacity
        ///// </summary>
        ///// <param name="capacity">The number of elements that new list can initially store</param>
        //public RoleCollection(int capacity)
        //    : base(capacity)
        //{
        //}

        /// <summary>
        ///  Construtor
        /// </summary>
        /// <param name="application"><see cref="Application"/> associada ao <see cref="Role"/></param>
        /// <param name="azRoleAssignments">RoleCollection do AzMan</param>
        internal RoleAssignmentCollection(Application application, IAzRoleAssignments azRoleAssignments)
        {
            if (azRoleAssignments == null)
            {
                throw new ArgumentNullException("azRoleAssignments");
            }

            foreach (IAzRoleAssignment azRoleAssignment in azRoleAssignments)
            {
                Add(new RoleAssignment(application, azRoleAssignment));
            }
        }

        //public void AddRange(RoleCollection roles)
        //{
        //    for (int roles = 0; roles < length; roles++)
        //    {
                
        //    }
        //}
        /// <summary>
        ///  Lista dos Nomes dos <see cref="RoleCollection"/>
        /// </summary>
        /// <returns>Array de String com os names dos <see cref="RoleCollection"/></returns>
        public string[] Names()
        {
            var names = new string[Count];

            for (var i = 0; i < Count; i++)
                names[i] = this[i].Name;

            return names;
        }
     }
}